<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<meta name="Generator" content="EditPlus®">
		<meta name="Author" content="梦想星辰大海">
		<meta name="Keywords" content="">
		<meta name="Description" content="">
		<title>cms后台模板</title>
		<link rel="stylesheet" href="${BASE_PATH}/static/book/res/lib/layui/css/layui.css">
	</head>
	<body>
		<form class="layui-form" action="borrow.htm" role="form" method="post">
			<div class="layui-form-item">
		        <label for="userId" class="layui-form-label">用户ID:</label>
				<div class="layui-input-block">
		      		<input type="text" name="userId" id="userId" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
	    		</div>
    		</div>
    		<div class="layui-form-item">
		    	<label for="bookId" class="layui-form-label">图书ID:</label>
		    	<div class="layui-input-block">
		      		<input type="text" name="bookId" id="bookId" lay-verify="title" autocomplete="off" placeholder="请输入标题" class="layui-input">
	    		</div>
		    </div>
		    <div class="layui-form-item">
		    	<label for="borrowTime" class="layui-form-label">借阅时间:</label>
		    	<div class="layui-input-block">
		      		<input class="layui-input" name="borrowTime" placeholder="自定义日期格式" onclick="layui.laydate({elem: this, istime: true, format: 'YYYY/MM/DD hh:mm:ss'})">
		      	</div>
		    </div>
			<div class="layui-form-item" style="float: right; margin-right: 100px;">
			    <button class="layui-btn" lay-submit="" lay-filter="ff">确认</button>
			    <a href="index.html" type="submit" class="layui-btn">返回</a>
	 		</div>
 		</form>
	</body>
	<script type="text/javascript" src="${BASE_PATH}/static/book/res/lib/layui/layui.js"></script>
	<script>
	layui.use(['form', 'layedit', 'laydate','jquery'], function(){
	  var form = layui.form()
	  ,layer = layui.layer
	  ,layedit = layui.layedit
	  ,laydate = layui.laydate
	  ,$ = layui.jquery;
	  
	  //创建一个编辑器
	  var editIndex = layedit.build('LAY_demo_editor');
	 
	  //自定义验证规则
	  form.verify({
	    title: function(value){
	      if(value.length < 1){
	        return '标题不能为空';
	      }
	    }
	    ,pass: [/(.+){6,12}$/, '密码必须6到12位']
	    ,content: function(value){
	      layedit.sync(editIndex);
	    }
	  });
	  
	  //监听指定开关
	  form.on('switch(switchTest)', function(data){
	    layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
	      offset: '6px'
	    });
	    layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
	  });
	  
	  //监听提交
		form.on('submit(ff)', function(data) {
			$.ajax({
				url:"borrow.json",
				type:"post",
				data:data.field,
				success:function(res){
					if(res.result){
						alert("添加成功")
						location.reload(); 
					}
				}
			})
			return false;
		});
	});
</script>
</html>
